package com.sg.service.biz.app.nb;

import cn.hutool.core.bean.BeanUtil;
import com.sg.common.util.CommonFunctionHelper;
import com.sg.dto.biz.app.req.*;
import com.sg.dto.biz.app.res.*;
import com.wicket.okrapp.common.baseinfo.BaseInfoDO;
import com.wicket.okrapp.common.baseinfo.BaseInfoHolder;
import org.apache.skywalking.apm.toolkit.trace.Tag;
import org.apache.skywalking.apm.toolkit.trace.Tags;
import org.apache.skywalking.apm.toolkit.trace.Trace;
import org.springframework.stereotype.Service;

/**
 * @author ： 手工接入方法
 * @version 1.0
 * @since 2022/5/28 15:32
 */
@Service
public class NbSystemTestDomain {
    /**
     * code:receptionService
     * name:M-构造业务时间验证数据
     * desc:undefined
     * gen by moon at 8/30/2022, 12:48:05 AM
     **/
    @Trace(operationName = "M-构造业务时间验证数据")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    public BuildBusTimeRespDto buildBusTime(BuildBusTimeReqDto reqDto) {
        BuildBusTimeRespDto retData = new BuildBusTimeRespDto();
        retData.setTime1(CommonFunctionHelper.str2Date(reqDto.getTime1()));
        retData.setTime2(CommonFunctionHelper.str2Date(reqDto.getTime2()));
        retData.setTime3(CommonFunctionHelper.str2Date(reqDto.getTime3()));
        retData.setTime4(CommonFunctionHelper.str2Date(reqDto.getTime4()));
        return retData;
    }

    /**
     * code:receptionService
     * name:M3-接收存档类型字段
     * desc:undefined
     * gen by moon at 8/30/2022, 12:48:07 AM
     **/
    @Trace(operationName = "M3-接收存档类型字段")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    public ObtainReceiveFieldRespDto obtainReceiveField(ObtainReceiveFieldReqDto reqDto) {
        return BeanUtil.toBean(reqDto, ObtainReceiveFieldRespDto.class);
    }

    /**
     * code:receptionService
     * name:M3-接收存档类型字段
     * desc:undefined
     * gen by moon at 8/30/2022, 12:48:07 AM
     **/
    @Trace(operationName = "M3-接收存档类型字段")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    public ObtainReceiveFieldRespDto obtainReceiveField2(ObtainReceiveFieldReqDto reqDto) {
        if (BaseInfoHolder.contextHolder.get() != null) {
            BaseInfoHolder.contextHolder.remove();
        }
        BaseInfoDO domain = new BaseInfoDO();
        domain.setSpecSpaceId(reqDto.getSpaceId());
        domain.setSpecInductionRecordId(reqDto.getCreateInductionId());
        domain.setSpecAppId(reqDto.getAppId());
        CommonFunctionHelper.setBaseInfoToLocal(domain);
        return BeanUtil.toBean(reqDto, ObtainReceiveFieldRespDto.class);
    }

    /**
     * code:generateSemanticInstance
     * name:M-生成语义内容实例(特殊方法）
     * desc:undefined
     * gen by moon at 8/30/2022, 12:48:16 AM
     **/
    @Trace(operationName = "M-生成语义内容实例(特殊方法）")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    public GenerateSemanticContInstanceRespDto generateSemanticContInstance(GenerateSemanticContInstanceReqDto reqDto) {
        GenerateSemanticContInstanceRespDto retData = new GenerateSemanticContInstanceRespDto();
        retData.setObjectName(reqDto.getCycleStandardName() + "_" + reqDto.getTargetContentName());
        return retData;
    }

    /**
     * code:receptionService
     * name:M-获取接收字段(测试-特殊方法）
     * desc:undefined
     * gen by moon at 8/31/2022, 4:20:36 PM
     **/
    @Trace(operationName = "M-获取接收字段(测试-特殊方法）")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    public ObtainTestReceiveFieldRespDto obtainTestReceiveField(ObtainTestReceiveFieldReqDto reqDto) {
        return BeanUtil.toBean(reqDto, ObtainTestReceiveFieldRespDto.class);
    }

    /**
     * code:getPublicFieldCache
     * name:M3推送业务应用公共字段缓存（特殊方法）
     * desc:undefined
     * gen by moon at 9/6/2022, 2:49:41 AM
     **/
    @Trace(operationName = "M3推送业务应用公共字段缓存（特殊方法）")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    public PutAppPublicFieldCacheRespDto putAppPublicFieldCache(PutAppPublicFieldCacheReqDto reqDto) {
        if (BaseInfoHolder.contextHolder.get() != null) {
            BaseInfoHolder.contextHolder.remove();
        }
        BaseInfoDO domain = new BaseInfoDO();
        domain.setSpecSpaceId(reqDto.getSpaceId());
        domain.setSpecInductionRecordId(reqDto.getCreateInductionId());
        domain.setSpecAppId(reqDto.getAppId());
        CommonFunctionHelper.setBaseInfoToLocal(domain);
        return BeanUtil.toBean(reqDto, PutAppPublicFieldCacheRespDto.class);
    }

    /**
     * code:receptionService
     * name:M3执行业务应用构造出入参字段（特殊方法）
     * desc:undefined
     * gen by moon at 9/10/2022, 1:49:08 AM
     **/
    @Trace(operationName = "M3执行业务应用构造出入参字段（特殊方法）")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    public ImplementBizConstructAccessParameterFieldRespDto implementBizConstructAccessParameterField(ImplementBizConstructAccessParameterFieldReqDto reqDto) {
        return BeanUtil.toBean(reqDto, ImplementBizConstructAccessParameterFieldRespDto.class);
    }

    /**
     * code:receptionService
     * name:M3执行接收字段入参（特殊方法）
     * desc:undefined
     * gen by moon at 4/26/2023, 7:01:52 PM
     **/
    @Trace(operationName = "M3执行接收字段入参（特殊方法）")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    public ImplementAcceptFieldRespDto implementAcceptField(ImplementAcceptFieldReqDto reqDto) {
        return BeanUtil.toBean(reqDto, ImplementAcceptFieldRespDto.class);
    }

    /**
     * code:receptionService
     * name:约定出参：当前用户是否小助手
     * desc:undefined
     * gen by moon at 6/6/2023, 6:31:06 AM
     **/
    @Trace(operationName = "约定出参：当前用户是否小助手")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    public CalculateAcceptAboveFieldsRespDto calculateAcceptAboveFields(CalculateAcceptAboveFieldsReqDto reqDto) {
        return BeanUtil.toBean(reqDto, CalculateAcceptAboveFieldsRespDto.class);
    }

    /**
     * code:publicFieldCache
     * name:M3执行业务应用公共字段推送内存（特殊方法）
     * desc:undefined
     * gen by moon at 6/11/2023, 6:41:00 AM
     **/
    @Trace(operationName = "M3执行业务应用公共字段推送内存（特殊方法）")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    public ImplementBizPublicFieldPushMemoryRespDto implementBizPublicFieldPushMemory(ImplementBizPublicFieldPushMemoryReqDto reqDto) {

        if (BaseInfoHolder.contextHolder.get() != null) {
            BaseInfoHolder.contextHolder.remove();
        }
        BaseInfoDO domain = new BaseInfoDO();
        domain.setSpecSpaceId(reqDto.getSpaceId());
        domain.setSpecInductionRecordId(reqDto.getCreateInductionId());
        domain.setSpecAppId(reqDto.getAppId());

        if (reqDto.getHighestOrgID() != null) {
            domain.setSpecHighestOrgID(reqDto.getHighestOrgID());
        }

        if (reqDto.getUserId() != null) {
            domain.setSpecUserId(reqDto.getUserId());
        }

        if (reqDto.getOriginalRoleMemberId() != null) {
            domain.setSpecOriginalRoleMemberId(reqDto.getOriginalRoleMemberId());
        }
        CommonFunctionHelper.setBaseInfoToLocal(domain);
        return new ImplementBizPublicFieldPushMemoryRespDto();
    }

    /**
     * code:receptionService
     * name:M3-接收入参字段
     * desc:undefined
     * gen by moon at 4/15/2024, 1:38:50 AM
     **/
    @Trace(operationName = "M3-接收入参字段")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    public ImplementEightReceivingFieldRespDto implementEightReceivingField(ImplementEightReceivingFieldReqDto reqDto) {
        return BeanUtil.toBean(reqDto, ImplementEightReceivingFieldRespDto.class);
    }

    /**
     * code:receptionService
     * name:M3接收事务批次标识与计算开始时间
     * desc:undefined
     * gen by moon at 6/13/2024, 4:03:11 PM
     **/
    @Trace(operationName = "M3接收事务批次标识与计算开始时间")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    public ImplementElevenReceivingFieldRespDto implementElevenReceivingField(ImplementElevenReceivingFieldReqDto reqDto) {
        return BeanUtil.toBean(reqDto, ImplementElevenReceivingFieldRespDto.class);
    }

    /**
     * code:receptionService
     * name:M3接收入参字段
     * desc:undefined
     * gen by moon at 7/20/2024, 6:26:21 PM
     **/
    @Trace(operationName = "M3接收入参字段")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    public ImplementFiveReceivingFieldRespDto implementFiveReceivingField(ImplementFiveReceivingFieldReqDto reqDto) {
        return BeanUtil.toBean(reqDto, ImplementFiveReceivingFieldRespDto.class);
    }
    //手工接入方法
}
